package com.leilei.serviceProject.domain.strategy.service.rule.tree.factory;

import com.leilei.serviceProject.domain.strategy.model.valobj.RaffleResultCheckVo;
import com.leilei.serviceProject.domain.strategy.model.valobj.RuleTreeVo;
import com.leilei.serviceProject.domain.strategy.service.rule.tree.ILogicTreeNode;
import com.leilei.serviceProject.domain.strategy.service.rule.tree.factory.engine.impl.RuleTreeEngine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author yanglei
 * @description 规则树引擎工厂
 * @create 2024/11/19 17:05
 */
@Service
public class DefaultTreeFactory {
    private final Map<String, ILogicTreeNode> logicTreeNodeGroup;

    public DefaultTreeFactory(Map<String, ILogicTreeNode> logicTreeNodeGroup) {
        this.logicTreeNodeGroup = logicTreeNodeGroup;
    }

    public RuleTreeEngine openTreeEngine(RuleTreeVo ruleTree) {
        return new RuleTreeEngine(logicTreeNodeGroup, ruleTree);
    }
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class TreeLogicResultEntity {
        private RaffleResultCheckVo ruleTreeResultCheck;
        private TreeResultData treeResultData;
    }
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class TreeResultData {
        private Integer awardId;
        private String awardRuleValue;
    }
}
